//
// Created by iris on 24-11-4.
//

#include "CodeGen/CGModule.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Constants.h"

void codegen::CGModule::run(std::vector<ASTBase*>* Mod) {
    // assert(Mod);
    // auto tf = llvm::dyn_cast<TestFunction>(Mod);
    auto builder = llvm::IRBuilder<>(getLLVMCtx());

    assert(Mod->size() == 1);
    auto tf = llvm::dyn_cast<DeclarationFunction>(Mod->at(0));

    // auto resTy = llvm::Type::getInt32Ty(getLLVMCtx());
    // auto fnTy = llvm::FunctionType::get(resTy, {}, false);
    // auto fn = llvm::Function::Create(fnTy, llvm::GlobalValue::ExternalLinkage, tf->name, getModule());
    //
    // auto bb = llvm::BasicBlock::Create(getLLVMCtx(), "entry", fn);
    // builder.SetInsertPoint(bb);
    //
    // auto zero = llvm::ConstantInt::get(getLLVMCtx(), llvm::APInt(32, 114514));
    // builder.CreateRet(zero);


}